package cn.xydpeng.springframework.context;

import java.time.Clock;
import java.util.EventObject;

/**
 * @author xydpeng
 * @version v1.0
 * @date: 2022/10/21
 * @description:
 */
public class ApplicationEvent extends EventObject {

    /**
     * System time when the event happened.
     */
    private final long timestamp;

    /**
     * Constructs a prototypical Event.
     *
     * @param source The object on which the Event initially occurred.
     * @throws IllegalArgumentException if source is null.
     */
    public ApplicationEvent(Object source) {
        super(source);
        this.timestamp = System.currentTimeMillis();
    }

    public ApplicationEvent(Object source, Clock clock) {
        super(source);
        this.timestamp = clock.millis();
    }


    public final long getTimestamp() {
        return timestamp;
    }
}
